/*
 Copyright (c) 2008 TPSi
 Alex Iskander
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:
 
 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 
 */


#ifndef BINDABLE_BINDABLE_RULE_H_
#define BINDABLE_BINDABLE_RULE_H_
#include "Bindable.h"

namespace Bind
{
	/**
	 \class Rule
	 \brief Abstract. Evaluates a condition.
	 
	 Rules are a useful tool which allow you to evaluate conditions within
	 BindableObjects. Rules get passed BindableObjects, and return a
	 score. Usually, the score will represent a boolean value; values less than
	 .5 are false, values equal or greater are true.
	 
	 Rules are most useful in situations where an object which is unaware of the
	 object needing evaluation (and thus has no idea how to evaluate it) needs
	 to evaluate an object. Simply pass the Rule object to the object which
	 needs to perform the evaluation.
	 
	 In the future, rules will be chainable, allowing very advanced logic to be
	 expressed; however, such advanced logic will likely be very slow. As such,
	 it may often be wise to write custom rules. To assist, a scripting language
	 may be provided at some point (as scripting would likely be faster than
	 the heavily-recursive and slow chaining), but such an undertaking has too
	 significant of demands currently.
	 
	 Rules are themselves BindableObject. This is often how they function.
	 A rule will have a property whose bindTo will be set.
	 
	 As such, many rules are templates.
	 
	 */
	
	class Rule : public Bindable
	{
		/**
		 \fn evaluate();
		 \brief Evaluates the rule.
		 
		 The return value will be a number between 0 and 1. The number
		 represents a score.
		 
		 To get a boolean value, which is usually equal to (evaluate() >= .5), 
		 you can call evaluateBoolean().
		 */
		virtual double evaluate() = 0;
		
		/**
		 \fn evaluateBoolean() = 0;
		 \brief Same as evaluate(), but returns false for values less than .5,
		 and true otherwise.
		 */
		virtual bool evaluateBoolean();
	};
}

#endif
